- Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathsource.cpp
51 lines (46 loc) · 1.38 KB
/
source.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#using <System.Windows.Forms.dll>
#using <System.Drawing.dll>
#using <System.dll>
#using <System.Data.dll>
usingnamespaceSystem;
usingnamespaceSystem::Data;
usingnamespaceSystem::ComponentModel;
usingnamespaceSystem::Windows::Forms;
public ref classForm1: publicForm
{
protected:
TextBox^ textBox1;
TextBox^ textBox2;
// <Snippet1>
private:
voidbutton1_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
// Takes the selected text from a text box and puts it on the clipboard.
if ( !textBox1->SelectedText->Equals( "" ) )
{
Clipboard::SetDataObject( textBox1->SelectedText );
}
else
{
textBox2->Text = "No text selected in textBox1";
}
}
voidbutton2_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
// Declares an IDataObject to hold the data returned from the clipboard.
// Retrieves the data from the clipboard.
IDataObject^ iData = Clipboard::GetDataObject();
// Determines whether the data is in a format you can use.
if ( iData->GetDataPresent( DataFormats::Text ) )
{
// Yes it is, so display it in a text box.
textBox2->Text = (String^)(iData->GetData( DataFormats::Text ));
}
else
{
// No it is not.
textBox2->Text = "Could not retrieve data off the clipboard.";
}
}
// </Snippet1>
};